package com.pdd.service.impl;

import com.pdd.beans.Comment;
import com.pdd.dao.CommentMapper;
import com.pdd.service.CommentService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论业务实现
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    @Setter
    private CommentMapper commentMapper;

    /**
     * 添加评论信息
     *
     * @param comment
     * @return
     */
    public boolean addComment(Comment comment) {
        return commentMapper.insertComment(comment)>0;
    }

    /**
     * 删除评论信息
     *
     * @param c_id
     * @return
     */
    public boolean delComment(int c_id) {
        return commentMapper.deleteComment(c_id)>0;
    }

    /**
     * 修改评论信息
     *
     * @param comment
     * @return
     */
    public boolean uplComment(Comment comment) {
        return commentMapper.updateComment(comment)>0;
    }

    /**
     * 查询所有评论信息
     *
     * @return
     */
    public List<Comment> getComment() {
        return commentMapper.selectComment();
    }

    /**
     * 根据商品ID查询评论信息
     *
     * @param p_id
     * @return
     */
    public Comment getById(int p_id) {
        return commentMapper.selectById(p_id);
    }
}
